<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\web\View;

/* @var $this yii\web\View */
/* @var $searchModel app\models\SchoolinfoSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '学籍信息';
$this->params['breadcrumbs'][] = $this->title;

$js=<<< Js
var exportLink = document.getElementById('export');
	exportLink.addEventListener('click', function(e){
		e.preventDefault();
		if(e.target.nodeName === "A"){
			tableExport('table-export', '导出文件', e.target.getAttribute('data-type'));
		}

	}, false);
Js;
$this->registerJs($js, View::POS_END, 'myAjax');
?>
<script src="<?= \Yii::getAlias('@web')?>/js/Blob.js"></script>
<script src="<?= \Yii::getAlias('@web')?>/js/FileSaver.js"></script>
<script src="<?= \Yii::getAlias('@web')?>/js/tableExport.js"></script>

<div class="schoolinfo-model-index">

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a('添加', ['create'], ['class' => 'btn btn-success']) ?>
          <div id="export" style="float: left;margin-right: 4px;" ><a class="btn btn-info"  data-type="xls" href="javascript:;">导出excel</a></div>
          <div id="import" ><a class="btn btn-info"  data-type="xls" href="<?=Yii::getAlias('@web'.'/schoolinfo/import')?>">导入excel</a></div>
    </p>
    <div class="table-responsive">
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
    		'tableOptions'=>[
    				'id'=>'table-export',
    				'class' => 'table table-striped table-bordered',
    		],
    
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

           // 'id',
            'stu_id',
        		'name',
        		'class_name',
            
            'stu_type'=>[
            		'value'=>function ($model){
            		if($model->stu_type==0)
            			$stu_type='本科生';
    		elseif ($model->stu_type==1)
    					$stu_type='硕士研究生';
    					else 
    						$stu_type='博士研究生';
            		return $stu_type;   	
    },
    'attribute'=>'stu_type',
    'filter'=>['0'=>'本科生','1'=>'硕士研究生','2'=>'博士研究生'],
    ],
    		'enroll_time',
            'major_name',
             
             'status'=>[
            		'value'=>function ($model){
            		if($model->status==0)
            			$status='在读';
			    		elseif ($model->status==1)
			    		$status='休学';
    					elseif($model->status==2) 
    					$status='退学';
    						elseif($model->status==3)
    						$status='保留入学资格';
    						elseif($model->status==4)
    						$status='毕业';
    						elseif($model->status==5)
    						$status='肄业';
    						elseif($model->status==7)
    						$status='在读（在外校交流）';
    						elseif($model->status==8)
    						$status='在本校交流学习';
    						elseif($model->status==9)
    						$status='在本校交流学习结束';
    						else
    						$status='开除';
            		return $status;   	
    },
    'attribute'=>'status',
    'filter'=>['0'=>'在读','1'=>'休学','2'=>'退学','3'=>'保留入学资格','4'=>'毕业','5'=>'肄业','6'=>'开除','7'=>'在读（在外校交流）',
    						'8'=>'在本校交流学习','9'=>'在本校交流学习结束'],
    ],
             

            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
    </div>
</div>
